<template>
	<div class="page">
		<template v-if="isLogin&&(type == 'map'||type == 'ssp'||type=='notice')">
			<web-view class="webview" :src="url"></web-view>
		</template> 
		<template v-else>
			<web-view class="webview" :src="url"></web-view>
		</template>
	</div>
</template>

<script>
	import {
		HTTP_REQUEST_URL
	} from '@/config.js'
	import {
		jsonToQuery
	} from '@/common/util.js'
	export default {
		name: '',
		data() {
			return {
				isLogin: false,
				url: '',
				params: {},
				userInfo: uni.getStorageSync('userInfo'),
				latitude:0,
				longitude:0
			}
		},
		async onLoad(params) { 
			console.log(params)
			 
			if(params.page_type){
				this.type = params.page_type;
			} 
			
			// 文章
			if(this.type=="article"){
				this.url=params.url;  
			}
			
			if (this.type == 'map'||this.type == 'notice'){
				this.isLogin = await this.$loginState('check');
			}
			
			
			if (this.isLogin) {
				if (this.type == 'map') {
					this.title = params.pname;
					let uid = params.uid;
					uid = uid && uid != 'undefined' ? uid : this.userInfo['id'];
					let url = '',
						cookiekey = uni.getStorageSync('cookiekey');
						
					// 监测地图
					if (params.type && params.type == 'jc') {
						if(params.search&&params.search==1){
							url=`${HTTP_REQUEST_URL}/yun-map/ydcmap?dataRange=${params.dataRange}&pagename=map&province=${params.province}&city=${params.city}&district=${params.district}&town=${params.town}&village=${params.village}&beginTime=${params.beginTime}&endTime=${params.endTime}&${cookiekey}`;
							console.log(2,url)
						}else{							
							url =
								`${HTTP_REQUEST_URL}/map/pcmap?pid=${params.pid}&uid=${uid}&dataRange=${params.dataRange}&type_code=pc_data&memberInfo=${params.memberInfo}&${cookiekey}`;
								console.log(1,url)
						}							
					}

					// 防控地图
					if (params.type && params.type == 'fk') {
						if(params.search&&params.search==1){
							url=`${HTTP_REQUEST_URL}/yun-map/yfkmap?dataRange=${params.dataRange}&pagename=map&province=${params.province}&city=${params.city}&district=${params.district}&town=${params.town}&village=${params.village}&beginTime=${params.beginTime}&endTime=${params.endTime}&${cookiekey}`;
						}else{
							url =
								`${HTTP_REQUEST_URL}/map/fkmap?pid=${params.pid}&uid=${uid}&dataRange=${params.dataRange}&type_code=fk_data&${cookiekey}`;
						}	
						
	
					}
					
					// 全民防控地图
					if (params.type && params.type == 'qmfk') {
						if(params.search&&params.search==1){
							url=`${HTTP_REQUEST_URL}/yun-map/yfkmap?dataRange=${params.dataRange}&pagename=map&province=${params.province}&city=${params.city}&district=${params.district}&town=${params.town}&is_qm=1&village=${params.village}&beginTime=${params.beginTime}&endTime=${params.endTime}&${cookiekey}`;
						}else{
							url =
								`${HTTP_REQUEST_URL}/map/fkmap?pid=${params.pid}&uid=${uid}&dataRange=${params.dataRange}&type_code=fk_data&${cookiekey}`;
						}	 
					}
					
					console.log(url)

					// 监理地图
					if (params.type && params.type == 'jl') {
						url =
							`${HTTP_REQUEST_URL}/map/jlpcmap?pid=${params.pid}&uid=${uid}&dataRange=${params.dataRange}&type_code=jl_data&${cookiekey}`;
					}

					// 公共地图
					if (params.type && params.type == 'public') {
						
						let all = params.all ? params.all : false;
						url =
							`${HTTP_REQUEST_URL}/map/publicpcmap?pid=${params.pid}&uid=${uid}&all=${all}&${cookiekey}`;
					}
					
					// 查询数据地图
					if (params.type && params.type == 'search') {
						
						let all = params.all ? params.all : false;
						url =
							`${HTTP_REQUEST_URL}/yun-map/yfkmap?dataRange=${params.dataRange}&pagename=map&province=${params.province}&city=${params.city}&district=${params.district}&town=${params.town}&village=${params.village}&beginTime=${params.beginTime}&endTime=${params.endTime}&${cookiekey}`;
						 
					}

					// 云调查地图
					if (params.project_type && params.project_type == "5") {
						url =
							`${HTTP_REQUEST_URL}/map/ydc?pid=${params.pid}&uid=${uid}&dataRange=${params.dataRange}&type_code=pc_data&memberInfo=${params.memberInfo}&${cookiekey}`;
					}
					  
					this.url = url; 
				}
				
				// 通知链接
				if(this.type=='notice'){
					this.url=params.url;
				}
			}
			
			
		},
		async onShow() {


		},
		methods: {
			
		},
		computed: {

		},
		components: {

		},
	}
</script>

<style lang="less">
	.webview {
		width: 100%;
		height: 100%;
	}
</style>
